package com.zlq.cn.controller.sign.lovers;


import com.zlq.cn.api.SignApiResult;
import com.zlq.cn.bootstrap.SignApiBootstrap;
import com.zlq.cn.config.Config;
import com.zlq.cn.dto.vo.SignCommonParam;
import com.zlq.cn.entity.LieYingService;
import com.zlq.cn.entity.LieYingTerminal;
import com.zlq.cn.entity.User;
import com.zlq.cn.service.un.LieYingServiceService;
import com.zlq.cn.service.un.LieYingTerminalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhoucl
 * @since 2022-05-16
 */
@Api(tags = "小情侣-猎鹰")
@RestController
@RequestMapping("/lovers/lie/ying")
public class LieYingServiceController {

    @Resource
    private LieYingServiceService lieYingServiceService;

    @Resource
    private LieYingTerminalService lieYingTerminalService;

    @ApiOperation("获取猎鹰服务信息")
    @PostMapping("/get/service")
    public SignApiResult<LieYingService> getService(@RequestBody SignCommonParam commonParam) {
        User user = SignApiBootstrap.requestUser();
        return SignApiResult.resultSuccess(
                lieYingServiceService.lambdaQuery()
                        .eq(LieYingService::getProject, Config.PROJECT_LOVERS)
                        .one()
        );
    }

    @ApiOperation("获取猎鹰终端信息信息")
    @PostMapping("/get/terminal")
    public SignApiResult<LieYingTerminal> getTerminal(@RequestBody SignCommonParam commonParam) {
        User user = SignApiBootstrap.requestUser();
        return SignApiResult.resultSuccess(
                lieYingTerminalService.lambdaQuery()
                        .eq(LieYingTerminal::getUserId,user.getId())
                        .eq(LieYingTerminal::getProject, Config.PROJECT_LOVERS)
                        .one()
        );
    }
}

